package com.lhnstart.learn.bases.date_;

import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 日期操作
 *
 * @author lhn
 * @date 2023/08/10 15:46
 * @since 1.0.0
 **/
public class DateCalendar {

    public static void main(String[] args) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date date = new Date();
        String today = dateFormat.format(date);
        System.out.println("today = " + today);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_MONTH, 5); // 增加5天
        Date calendarTime = calendar.getTime();
        String format = dateFormat.format(calendarTime);
        System.out.println("format = " + format);


    }

}